package com.onesports.intelligent.k12.polarlight.security;


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.onesports.intelligent.k12.polarlight.domain.vo.auth.DataPermissionVO;
import com.onesports.intelligent.k12.polarlight.serializer.CustomAuthorityDeserializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;


/**
 * @author aj
 */
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class DomainUserDetails implements UserDetails, Serializable {
    private static final long serialVersionUID = 1L;

    public static final String ANONYMOUS_USER = "anonymous";

    private String username;

    @JsonIgnore
    private String password;
    /**
     * 权限
     */
    @JsonDeserialize(using = CustomAuthorityDeserializer.class)
    private Collection<? extends GrantedAuthority> authorities;
    /**
     * 账户未过期
     */
    @Builder.Default
    private boolean accountNonExpired = true;
    /**
     * 账户未锁定
     */
    @Builder.Default
    private boolean accountNonLocked = true;
    /**
     * 认证未过期
     */
    @Builder.Default
    private boolean credentialsNonExpired = true;
    /**
     * 账户是否可用
     */
    @Builder.Default
    private boolean enabled = true;
    /**
     * 用户Id
     */
    private String current;

    private String phone;
    /**
     * 所属系统
     */
    private String systemCode;
    /**
     * 单位
     */
    private String organizationId;

    /**
     * 职工id
     */
    private String staffId;

    private String nickname;

    private String gender;

    private String avatar;
    /**
     * 是否首次登录
     */
    private boolean firstTimeLogin;
    /**
     * 是否超管
     */
    private boolean superAdmin;
    /**
     * 是否教练
     */
    private boolean coach;
    /**
     * 教练id
     */
    private String coachId;
    /**
     * 员工校区集合
     */
    private List<String> campusIds;
    /**
     * 数据权限
     */
    private DataPermissionVO dataPermissionVO;
}
